package com.book.book.service.impl;

import com.book.book.service.SolrService;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.springframework.stereotype.Service;

/**
 * Created by siyuan on 2018/3/15.
 */



@Service
public class SolrServiceImpl implements SolrService {

    /**
     * 查询数据的图书
     *
     * @return
     */
    @Override
    public void SearchBook(SolrQuery solrQuery) throws SolrServerException {
//
//        //根据查询条件搜索索引库
//        QueryResponse response = solrServer.query(solrQuery);
//        //取商品列表
//        SolrDocumentList documentList = response.getResults();
//
//        //商品列表
//        List<BooksDO> itemList = new ArrayList<>();
//
//        for (SolrDocument solrDocument : documentList) {
//            // 查询要缓存的图书列表
//            BooksDO book = new BooksDO();
//            book.setBookId((Integer) solrDocument.get("book_id"));
//            //取高亮显示
//            Map<String, Map<String, List<String>>> highlighting = response.getHighlighting();
//            List<String> list = highlighting.get(solrDocument.get("id")).get("item_title");
//            String title = "";
//            if (null != list && !list.isEmpty()) {
//                title = list.get(0);
//            } else {
//                title = (String) solrDocument.get("item_title");
//            }
//
//            itemList.add(book);
//        }
//
//        //商品列表
//        SearchResult searchResult = new SearchResult();
//        searchResult.setItemList(itemList);
//        //返回带参数的页数
//        searchResult.setRecordCount(documentList.getNumFound());
//
//        return searchResult;


    }
}
